var currentHost = document.location.host.toLowerCase();

if (document.title.indexOf("Kooboo CMS") >= 0) {
  chrome.extension.sendMessage(
    {
      target: "background",
      currentHost: currentHost,
      currentSite: getCurrentKoobooSite()
    }, 
    function(response) {
    }
  );
};

function getCurrentKoobooSite(){
  var repository = "";
  var siteName = "";

  var $db_start_hypherlink = $("li.Repository ul li.Home a", $("#sidebar"));
  if ($db_start_hypherlink != null) {
    var href = $db_start_hypherlink.attr("href");
    
    repository = href.substring(href.indexOf("repositoryName=") + 15, href.indexOf("&"));
    siteName = href.substring(href.indexOf("siteName=") + 9);
  };

  return{
    Host: currentHost,
    Name: siteName,
    Repository: repository
  };
}